<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>会员登入</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="../res/layui/css/layui.css" rel="stylesheet">
  <link href="../res/adminui/dist/css/admin.css" rel="stylesheet">
  <link href="../res/adminui/dist/css/login.css" rel="stylesheet">
</head>
<body>
  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>会员登入</h2>
        <p> </p>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
          <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
          <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
        </div>
        <div class="layui-form-item" style="margin-bottom: 20px;">
          <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
					 <a href="reg.html" class="layadmin-user-jump-change layadmin-link">注册帐号</a>
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
        </div>
      </div>
    </div>
    <div class="layui-trans layadmin-user-login-footer">
      <p>© All Rights Reserved</p>
    </div>
  </div>

<script src="../res/layui/layui.js"></script>  
<script>
layui.use(['form','layer'], function(){
  var form = layui.form;
  var layer = layui.layer;

    //提交
    form.on('submit(LAY-user-login-submit)', function(obj){
            field = obj.field;

      var xmlhttp = new XMLHttpRequest(); // 创建一个新的XMLHttpRequest对象
      xmlhttp.onreadystatechange = function() {
      	if (this.readyState == 4 && this.status == 200) {
					if(this.responseText==1){
      			layer.msg('登入成功',{icon:1}, function(){
             location.href = '/member'; //跳转到主页
            });
      	  }else if(this.responseText==0){
					layer.msg('用户名或密码错误',{icon:2});
				   }
			  }
      };
      xmlhttp.open("POST", "make.php",true); // 发送POST请求，将数据传递给服务器端PHP脚本
      xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      xmlhttp.send("username_login=" + field.username  + "&password_login="+ field.password);	
    });

  });
  </script>
</body>
</html>